<!DOCTYPE html >
<html xmlns:th="http://www.thymeleaf.org">
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
        <title>登陆</title>
        <script th:src="@{/erp/js/jquery1.9.0.min.js}"></script>
        <script type="text/javascript" th:src="@{/erp/js/jquery.SuperSlide.2.1.js}"></script>
        <script th:src="@{/erp/assets/layer/layer.js}" type="text/javascript"></script>
        <link th:href="@{/erp/css/css.css}" rel="stylesheet" type="text/css"/>
    </head>

    <body>
        <!-- 大图片 -->
        <div class="fullSlide">
            <div class="bd">
                <ul>
                    <li _src="url(/erp/images/bg1.jpg)" style="background:#E2025E center 0 no-repeat;"></li>
                    <li _src="url(/erp/images/bg2.jpg)" style="background:#DED5A1 center 0 no-repeat;"></li>
                </ul>
            </div>
            <div class="hd">
                <ul>
                </ul>
            </div>
            <span class="prev"></span> <span class="next"></span></div>
        <!-- 大图片 -->
        <div class="login_r">
            <div class="right-content">

                <div class="login-header">
                    <div class="brand">速登云ERP系统</div>
                </div>
                <form id="login_form">
                    <div class="login-content tab-content">
                        <div class="tab-pane fade in active" id="company_user">
                            <!--<label id="msg"></label>-->
                            <div class="form-group m-b-15">
                                <input name="account" id="usercount" class="form-control input-lg" placeholder="请输入账号"
                                       style="font-size: 16px" type="text">
                            </div>
                            <input name="type" value="1" type="hidden">
                            <label style="color: red" th:text="${msg}"></label>
                            <div class="form-group m-b-15">
                                <input name="password" id="password" class="form-control input-lg" placeholder="请输入密码"
                                       style="font-size: 16px" type="password">
                            </div>
                            <div class="form-group">
                                <div class="input-group">
                                    <input name="code" id="code"
                                           style="width: 30%; font-size: 16px; height: 32px; margin-right: 10px; float:left;"
                                           placeholder="请输入验证码" class="form-control" maxlength="4" type="text">
                                    <img class="jcaptcha-btn jcaptcha-img code-img img" src="/code" id="img"
                                         title="点击更换验证码"
                                         style="border: 1px solid #AAA; margin-right: 10px; cursor: pointer;float:left;"/></p>
                                    <a class="jcaptcha-btn img">点击图片切换</a></div>
                            </div>
                            <div class="login-buttons">
                                <input type="button" class="btn btn-primary btn-block btn-lg btn-submit btn-green"
                                       id="login_btn" value="登录"/>
                            </div>
                            <hr class="hr_ex">
                            <div class="form-group">
                                <div class="col-sm-12"> 没有注册账号，赶快<a href="/toregister" style="color: #00b7ee"> 注册 </a>吧。
                                </div>
                            </div>
                        </div>
                    </div>
                </form>
                <script>
                    var companyUser = document.getElementById("company_user");
                    companyUser.className += " active"
                </script>
            </div>

        </div>
        <div class="system-notice">
            <div class="form-group" style="margin-bottom:0;">
                <div class="col-sm-12">
                    [友情链接]：<a href="#" target="_blank">友情链接</a>|<a href="#" target="_blank">友情链接</a>|<a href="#"
                                                                                                        target="_blank">友情链接</a>|<a
                        href="#" target="_blank">友情链接</a>|<a href="#" target="_blank">友情链接</a>|<a href="#"
                                                                                                  target="_blank">友情链接</a>|<a
                        href="#" target="_blank">友情链接</a>|<a href="#" target="_blank">友情链接</a></div>
                <div class="col-sm-12">
                    <a href="#" target="_blank">诚征英才</a>|<a href="#" target="_blank">联系我们</a>|版权所有：<a href="#"
                                                                                                      target="_blank">武汉群翔技术有限公司</a>
                </div>
                <div class="col-sm-12">
                    Copyright ©360.cn..京ICP证080047号
                    京公网安备11000002000006号 中国互联网举报中心
                </div>
            </div>
        </div>
        <script type="text/javascript" th:inline="javascript">

            $(function () {

                $("#usercount").blur(function () {
                    if ($(this).val().length == 0) {
                        layer.tips('请输入用户名!', '#usercount', {
                            tips: [2, 'red'],
                            time: 2000
                        });
                    }
                })
                $("#password").blur(function () {
                    if ($(this).val().length == 0) {
                        layer.tips('请输入密码!', '#password', {
                            tips: [2, 'red'],
                            time: 2000
                        });
                    }
                })
                $("#code").blur(function () {
                    if ($(this).val().length == 0) {
                        layer.tips('请输入验证码!', '#code', {
                            tips: [4, 'red'],
                            time: 2000
                        });
                    }
                })

            })

            $("#login_btn").on("click", function () {
                if ($("#usercount").val().length == 0) {
                    layer.tips('请输入用户名!', '#usercount', {
                        tips: [2, 'red'],
                        time: 2000
                    });
                } else if ($("#password").val().length == 0) {
                    layer.tips('请输入密码!', '#password', {
                        tips: [2, 'red'],
                        time: 2000
                    });
                } else if ($("#code").val().length == 0) {
                    layer.tips('请输入验证码!', '#code', {
                        tips: [4, 'red'],
                        time: 2000
                    });
                } else {

                    $.ajax({
                        url: '/login2',
                        data: {
                            "account": $("#usercount").val(),
                            "password": $("#password").val(),
                        },
                        contentType: 'application/json',           //表示我们发送给服务器数据是json格式
                        dataType: 'json',                          //表示服务器返回给我们的数据是json格式
                        success: function (data) {
                            if (data.result == true) {
                                $.ajax({
                                    url: '/login1',
                                    data: {
                                        "account": $("#usercount").val(),
                                        "password": $("#password").val(),
                                        "code": $("#code").val()
                                    },
                                    contentType: 'application/json',           //表示我们发送给服务器数据是json格式
                                    dataType: 'json',                          //表示服务器返回给我们的数据是json格式
                                    success: function (data) {
                                        if (data.result == false) {
                                            layer.tips('验证码错误!', '#code', {
                                                tips: [4, 'red'],
                                                time: 2000
                                            });
                                            $(".code-img").attr("src", "/code?x=" + Math.random());
                                        } else {
                                            $.ajax({
                                                url: '/login3',
                                                contentType: 'application/json',           //表示我们发送给服务器数据是json格式
                                                dataType: 'json',                          //表示服务器返回给我们的数据是json格式
                                                success: function (data) {
                                                    if (data.result == "no") {
                                                        layer.msg('当前员工账号未启用！', {icon: 2, time: 2000}, function () {
                                                            window.location.href = "/logout";
                                                        });
                                                    } else if (data.result == false) {
                                                        layer.msg('当前企业账号未启用！', {icon: 2, time: 2000}, function () {
                                                            window.location.href = "/logout";
                                                        });
                                                    } else {
                                                        layer.msg('登录成功！', {icon: 1, time: 1000}, function () {
                                                            window.location.href = "/index";
                                                        });
                                                    }
                                                }
                                            })

                                        }
                                    }
                                })

                            } else if (data.result == "userFalse") {
                                layer.tips('用户名不存在!', '#usercount', {
                                    tips: [2, 'red'],
                                    time: 2000
                                });
                            } else if (data.result == "passwordFalse") {
                                layer.tips('密码错误!', '#password', {
                                    tips: [2, 'red'],
                                    time: 2000
                                });
                            } else if (data.result == "Locked") {
                                layer.tips('用户被锁定了!', '#password', {
                                    tips: [2, 'red'],
                                    time: 2000
                                });
                            }
                        }
                    })

                }
                return false;
            })

            /* 控制左右按钮显示 */
            jQuery(".fullSlide").hover(function () {
                jQuery(this).find(".prev,.next").stop(true, true).fadeTo("show", 0.5)
            }, function () {
                jQuery(this).find(".prev,.next").fadeOut()
            });
            /* 调用SuperSlide */
            jQuery(".fullSlide").slide({
                titCell: ".hd ul", mainCell: ".bd ul", effect: "fold", autoPlay: true, autoPage: true, trigger: "click",
                startFun: function (i) {
                    var curLi = jQuery(".fullSlide .bd li").eq(i); /* 当前大图的li */
                    if (!!curLi.attr("_src")) {
                        curLi.css("background-image", curLi.attr("_src")).removeAttr("_src") /* 将_src地址赋予li背景，然后删除_src */
                    }
                }
            });

            $(".img").on("click", function () {
                $(".code-img").attr("src", "/code?x=" + Math.random());
            })

        </script>
    </body>
</html>
